"""
  模块描述：实体类
  @author 8526
  @date 2022-05-16 9:27:55
  版权所有 Copyright www.dahantc.com
"""


# 隐号起始呼叫推送数据
class HiddenNumStartCallResponse:
    data = []

    def __init__(self, data):
        self.data = data


# 隐号起始呼叫详情数据
class HiddenNumStartCallData:
    # 请求号码时，所带msgid
    msgid = ''
    # 区分推送话单唯一性
    callid = ''
    # 被叫来显号码
    calldisplay = ''
    # 发起呼叫时间，格式：yyyy-mm-dd hh:mm:ss
    calltime = ''
    # 真实号码
    telA = ''
    # 对端号码
    telB = ''
    # 录音控制, 0：不录音 1：接通后录音 2：被叫响铃后录音
    callrecording = ''
    # 呼叫类型：
    # 10：通话主叫
    # 11：通话被叫
    # 12：短信发送
    # 13：短信接收
    # 20：呼叫不允许
    # 21: 未开户不允许
    # 30：短信不允许
    # 31：转接短信
    # 126: 双呼
    calltype = ''

    def __init__(self, msgid, callid, calldisplay, calltime, telA, telB, callrecording, calltype):
        self.msgid = msgid
        self.callid = callid
        self.calldisplay = calldisplay
        self.calltime = calltime
        self.telA = telA
        self.telB = telB
        self.callrecording = callrecording
        self.calltype = calltype


def hiddenNumStartCallResponseDecoder(obj):
    if obj is None:
        return None
    return HiddenNumStartCallResponse(
        hiddenNumStartCallDataDecoder(obj.get('data')))


def hiddenNumStartCallDataDecoder(obj):
    if obj is None:
        return None
    data = []
    for val in obj:
        data.append(
            HiddenNumStartCallData(val.get('msgid'), val.get('callid'), val.get('calldisplay'), val.get('calltime')
                                   , val.get('telA'), val.get('telB'), val.get('callrecording')
                                   , val.get('calltype')))
    return data


# 语音文件响应
class VoiceSmsFileResponse:
    #  请求结果
    result = ''
    # 描述
    desc = ''
    data = []

    def __init__(self, result, desc, data):
        self.result = result
        self.desc = desc
        self.data = data


# 语音文件详情数据
class VoiceSmsFileData:
    # 客户账号
    account = ''
    # 语音文件标识id
    mfid = ''
    # 语音文件状态，0：文件被删除，1：审核通过，2：审核驳回，3：审核失败
    status = ''
    # 审核说明
    remark = ''
    # 审核时间，格式：yyyy-MM-dd HH:mm:ss
    auditTime = ''

    def __init__(self, account, mfid, status, remark, auditTime):
        self.account = account
        self.mfid = mfid
        self.status = status
        self.remark = remark
        self.auditTime = auditTime


def voiceSmsFileResponseDecoder(obj):
    if obj is None:
        return None
    return VoiceSmsFileResponse(obj.get('result'), obj.get('desc'),
                                voiceSmsFileDataDecoder(obj.get('data')))


def voiceSmsFileDataDecoder(obj):
    if obj is None:
        return None
    data = []
    for val in obj:
        data.append(
            VoiceSmsFileData(val.get('account'), val.get('mfid'), val.get('status'), val.get('remark')
                             , val.get('auditTime')))
    return data
